#include<bits/stdc++.h>
using namespace std;
struct number
{
	int d,v,a;
}a[100005];
int b[100005];
int n,m,l,V;
int f[100005];
int t;
int find(int s)
{
	for(int i=1;i<=m;i++)
	{
		if(s<b[i]) return i;
	}
	return -1;
}
int find2(int l,int r)
{
	for(int i=1;i<=m;i++)
	{
		if(b[i]<=r&&b[i]>=l) return i;
	}
	return -1;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&t);
	while(t--)
	{
		
		scanf("%d%d%d%d",&n,&m,&l,&V);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d%d",&a[i].d,&a[i].v,&a[i].a);
		}
		for(int i=1;i<=m;i++)
		{
			scanf("%d",&b[i]);
		}
		sort(b+1,b+m+1);
		int ans1=0,ans2=m;
		for(int i=1;i<=n;i++)
		{
			if(a[i].a==0)
			{
				int k=find(a[i].d);
				
				if(a[i].v>V&&k!=-1)
				{
					ans1++;
					//cout<<k<<endl;
					if(f[k]==0)
					{
						ans2--;
						f[k]=1;
					}
				}
			}
			else if(a[i].a<0)
			{
				if(a[i].v<=V) continue;
				double t=0.1;
				while(a[i].a*2*a[i].v*t+a[i].a*a[i].a*t*t>V-a[i].v*a[i].v) t=t+0.1;
				double s1=a[i].v*t+0.5*a[i].a*t*t+a[i].d;
				int k=find2(a[i].d,s1);
				//cout<<t<<" "<<s1<<" "<<k<<endl;
				if(k!=-1)
				{
					ans1++;
					if(f[k]==0)
					{
						ans2--;
					}
					for(int j=k;j<=m;j++) f[j]=1;
				}

			}
			else
			{
				double t=0.1;
				while(a[i].a*2*a[i].v*t+a[i].a*a[i].a*t*t<=V-a[i].v*a[i].v) t=t+0.1;
				double s=a[i].v*t+0.5*a[i].a*t*t+a[i].d;
				int k=find(s);
				//cout<<t<<" "<<s<<" "<<k<<endl;
				if(s<=l&&k!=-1)
				{
					ans1++;
					if(f[k]==0)
					{
						ans2--;
						f[k]=1;
					}
					for(int j=k;j<=m;j++) f[j]=1;
				}
			}
			
		}
		printf("%d %d\n",ans1,ans2);
	}
	return 0;
}
